package ModelLayer;

import java.util.ArrayList;

public class Facility {
	private long ID;
	private String name;
	private ArrayList<ActivityType> activities;

	public Facility() {
		this.activities = new ArrayList<ActivityType>();
	}

	public Facility(long ID) {
		this.ID = ID;
		this.activities = new ArrayList<ActivityType>();
	}

	public long getID() {
		return ID;
	}

	public void setID(long facilityId) {
		this.ID = facilityId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ArrayList<ActivityType> getActivities() {
		return activities;
	}

	public ActivityType getActivity(long ID) {
		ActivityType at = new ActivityType();
		for (ActivityType a : activities) {
			if (a.getID() == ID)
				at = a;
			else
				at = null;
		}

		return at;
	}

	public void addActivity(ActivityType activity) {
		this.activities.add(activity);
	}

	public void removeActivity(ActivityType activity) {
		for (ActivityType ac : activities) {
			if (ac.getID() == activity.getID()) {
				try {
					activities.remove(ac);
				} catch (Exception e) {
					System.out.println("Problem removing Activity "
							+ activity.getID() + ": " + e.getMessage());
				}
			}
		}
	}

	public void updateActivity(ActivityType activity) {
		for (ActivityType ac : activities) {
			if (ac.getID() == activity.getID()) {
				activities.set(activities.indexOf(ac), activity);
			}
		}
	}

	public boolean hasActivity(long ID) {
		boolean has = false;

		for (ActivityType a : activities) {
			if (a.getID() == ID)
				has = true;
		}

		return has;
	}
}
